﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package com.facebook.data {
    import flash.events.*;
    import com.facebook.errors.*;
    import com.adobe.serialization.json.*;
    import com.facebook.utils.*;
    import com.facebook.data.users.*;
    import com.facebook.data.photos.*;
    import com.facebook.data.status.*;
    import com.facebook.data.fbml.*;
    import com.facebook.data.data.*;
    import com.facebook.data.notes.*;
    import com.facebook.commands.data.*;
    import com.facebook.data.application.*;
    import com.facebook.data.feed.*;
    import com.facebook.data.admin.*;
    import com.facebook.data.events.*;
    import com.facebook.data.friends.*;
    import com.facebook.data.pages.*;
    import com.facebook.data.notifications.*;
    import com.facebook.data.groups.*;
    import com.facebook.data.auth.*;
    import com.facebook.data.batch.*;

    public class XMLDataParser implements IFacebookResultParser {

        protected var fb_namespace:Namespace;

        public function XMLDataParser(){
            this.fb_namespace = new Namespace("http://api.facebook.com/1.0/");
        }
        protected function parseSendEmail(_arg1:XML):ArrayResultData{
            var _local2:ArrayResultData = new ArrayResultData();
            _local2.arrayResult = FacebookXMLParserUtils.toArray(_arg1);
            return (_local2);
        }
        protected function parseGetPhotos(_arg1:XML):GetPhotosData{
            var _local4:*;
            var _local5:PhotoData;
            var _local2:GetPhotosData = new GetPhotosData();
            var _local3:PhotoCollection = new PhotoCollection();
            for each (_local4 in _arg1..this.fb_namespace::photo) {
                _local5 = new PhotoData();
                _local5.pid = _local4.this.fb_namespace::pid;
                _local5.aid = _local4.this.fb_namespace::aid;
                _local5.owner = _local4.this.fb_namespace::owner;
                _local5.src = _local4.this.fb_namespace::src;
                _local5.src_big = _local4.this.fb_namespace::src_big;
                _local5.src_small = _local4.this.fb_namespace::src_small;
                _local5.caption = _local4.this.fb_namespace::caption;
                _local5.created = FacebookXMLParserUtils.toDate(_local4.this.fb_namespace::created);
                _local3.addPhoto(_local5);
            };
            _local2.photoCollection = _local3;
            return (_local2);
        }
        protected function parseGetNotifications(_arg1:XML):GetNotificationData{
            var _local4:*;
            var _local5:*;
            var _local6:*;
            var _local7:NotificationMessageData;
            var _local8:NotificationPokeData;
            var _local9:NotificationShareData;
            var _local2:GetNotificationData = new GetNotificationData();
            var _local3:NotificationCollection = new NotificationCollection();
            for each (_local4 in _arg1.this.fb_namespace::messages) {
                _local7 = new NotificationMessageData();
                _local7.unread = _local4.this.fb_namespace::unread;
                _local7.most_recent = _local4.this.fb_namespace::most_recent;
                _local3.addItem(_local7);
            };
            for each (_local5 in _arg1.this.fb_namespace::pokes) {
                _local8 = new NotificationPokeData();
                _local8.unread = _local5.this.fb_namespace::unread;
                _local8.most_recent = _local5.this.fb_namespace::most_recent;
                _local3.addItem(_local8);
            };
            for each (_local6 in _arg1.this.fb_namespace::shares) {
                _local9 = new NotificationShareData();
                _local9.unread = _local6.this.fb_namespace::unread;
                _local9.most_recent = _local6.this.fb_namespace::most_recent;
                _local3.addItem(_local9);
            };
            _local2.friendsRequests = FacebookXMLParserUtils.toUIDArray(_arg1.this.fb_namespace::friend_requests[0]);
            _local2.group_invites = FacebookXMLParserUtils.toUIDArray(_arg1.this.fb_namespace::group_invites[0]);
            _local2.event_invites = FacebookXMLParserUtils.toUIDArray(_arg1.this.fb_namespace::event_invites[0]);
            _local2.notificationCollection = _local3;
            return (_local2);
        }
        public function createFacebookError(_arg1:Object, _arg2:String):FacebookError{
            var _local3:FacebookError = new FacebookError();
            _local3.rawResult = _arg2;
            _local3.errorCode = FacebookErrorCodes.SERVER_ERROR;
            if ((_arg1 is Error)){
                _local3.error = (_arg1 as Error);
            } else {
                _local3.errorEvent = (_arg1 as ErrorEvent);
            };
            return (_local3);
        }
        protected function getAffiliation(_arg1:XML):AffiliationCollection{
            var _local3:*;
            var _local4:AffiliationData;
            var _local2:AffiliationCollection = new AffiliationCollection();
            for each (_local3 in _arg1..this.fb_namespace::afflication) {
                _local4 = new AffiliationData();
                _local4.nid = _local3.this.fb_namespace::nid;
                _local4.name = _local3.this.fb_namespace::name;
                _local4.type = _local3.this.fb_namespace::type;
                _local4.status = _local3.this.fb_namespace::status;
                _local4.year = _local3.this.fb_namespace::year;
                _local2.addAffiliation(_local4);
            };
            return (_local2);
        }
        protected function parseGetUserPreferences(_arg1:XML):GetUserPreferencesData{
            var _local4:*;
            var _local5:PreferenceData;
            var _local2:GetUserPreferencesData = new GetUserPreferencesData();
            var _local3:PreferenceCollection = new PreferenceCollection();
            for each (_local4 in _arg1..this.fb_namespace::preference) {
                _local5 = new PreferenceData();
                _local5.pref_id = _local4.this.fb_namespace::pref_id;
                _local5.value = _local4.this.fb_namespace::value;
                _local3.addItem(_local5);
            };
            _local2.perferenceCollection = _local3;
            return (_local2);
        }
        public function parse(_arg1:String, _arg2:String):FacebookData{
            var _local3:FacebookData;
            var _local4:XML = new XML(_arg1);
            switch (_arg2){
                case "application.getPublicInfo":
                    _local3 = this.parseGetPublicInfo(_local4);
                    break;
                case "data.getCookies":
                    _local3 = this.parseGetCookies(_local4);
                    break;
                case "admin.getAllocation":
                    _local3 = this.parseGetAllocation(_local4);
                    break;
                case "admin.getAppProperties":
                    _local3 = this.parseGetAppProperties(_local4);
                    break;
                case "admin.getMetrics":
                    _local3 = this.parseGetMetrics(_local4);
                    break;
                case "auth.getSession":
                    _local3 = new GetSessionData();
                    (_local3 as GetSessionData).expires = FacebookXMLParserUtils.toDate(_local4.this.fb_namespace::expires);
                    (_local3 as GetSessionData).uid = FacebookXMLParserUtils.toStringValue(_local4.this.fb_namespace::uid[0]);
                    (_local3 as GetSessionData).session_key = _local4.this.fb_namespace::session_key.toString();
                    (_local3 as GetSessionData).secret = String(_local4.this.fb_namespace::secret);
                    break;
                case "feed.getRegisteredTemplateBundles":
                    _local3 = this.parseGetRegisteredTemplateBundles(_local4);
                    break;
                case "friends.areFriends":
                    _local3 = this.parseAreFriends(_local4);
                    break;
                case "notes.get":
                    _local3 = this.parseGetNotes(_local4);
                    break;
                case "friends.get":
                    _local3 = this.parseGetFriends(_local4);
                    break;
                case "friends.getAppUsers":
                    _local3 = this.parseGetAppUsersData(_local4);
                    break;
                case "friends.getLists":
                    _local3 = this.parseGetLists(_local4);
                    break;
                case "groups.get":
                    _local3 = this.parseGetGroups(_local4);
                    break;
                case "data.getAssociationDefinitions":
                    _local3 = new FacebookData();
                    break;
                case "data.getAssociationDefinition":
                    _local3 = new FacebookData();
                    break;
                case "data.getObject":
                case "data.getObjects":
                    _local3 = new FacebookData();
                    break;
                case "groups.getMembers":
                    _local3 = this.parseGetGroupMembers(_local4);
                    break;
                case "users.getInfo":
                    _local3 = this.parseGetInfo(_local4);
                    break;
                case "data.createObject":
                case "data.setHashValue":
                case "connect.getUnconnectedFriendsCount":
                case "feed.registerTemplateBundle":
                    _local3 = new NumberResultData();
                    (_local3 as NumberResultData).value = FacebookXMLParserUtils.toNumber(_local4);
                    break;
                case "notifications.get":
                    _local3 = this.parseGetNotifications(_local4);
                    break;
                case "feed.getRegisteredTemplateBundleByID":
                    _local3 = this.parseGetRegisteredTemplateBundleByID(_local4);
                    break;
                case "users.getStandardInfo":
                    _local3 = this.parseGetStandardInfo(_local4);
                    break;
                case "feed.getRegisteredTemplateBundles":
                    _local3 = this.parseGetRegisteredTemplateBundles(_local4);
                    break;
                case "data.getUserPreferences":
                    _local3 = this.parseGetUserPreferences(_local4);
                    break;
                case "users.isAppUser":
                case "users.hasAppPermission":
                case "users.setStatus":
                case "pages.isFan":
                case "pages.isAppAdded":
                case "pages.isAdmin":
                case "admin.setAppProperties":
                case "auth.expireSession":
                case "auth.revokeAuthorization":
                case "events.cancel":
                case "events.edit":
                case "events.rsvp":
                case "liveMessage.send":
                case "data.undefineAssociation":
                case "data.defineAssociation":
                case "data.removeHashKeys":
                case "data.removeHashKey":
                case "data.incHashValue":
                case "data.updateObject":
                case "data.deleteObject":
                case "data.deleteObjects":
                case "data.renameAssociation":
                case "data.setObjectProperty":
                case "profile.setInfo":
                case "profile.setInfoOptions":
                case "feed.deactivateTemplateBundleByID":
                case "feed.publishTemplatizedAction":
                case "admin.setRestrictionInfo":
                case "data.setCookie":
                case "data.createObjectType":
                case "notes.delete":
                case "notes.edit":
                case "data.setUserPreference":
                case "data.dropObjectType":
                case "data.renameObjectType":
                case "fbml.registerCustomTags":
                case "fbml.deleteCustomTags":
                case "fbml.refreshRefUrl":
                case "fbml.refreshImgSrc":
                case "fbml.setRefHandle":
                case "data.setUserPreferences":
                case "data.defineObjectProperty":
                case "photos.addTag":
                case "stream.addLike":
                case "stream.removeLike":
                case "stream.removeComment":
                case "sms.canSend":
                    _local3 = new BooleanResultData();
                    (_local3 as BooleanResultData).value = FacebookXMLParserUtils.toBoolean(_local4);
                    break;
                case "feed.publishUserAction":
                    _local3 = new BooleanResultData();
                    (_local3 as BooleanResultData).value = FacebookXMLParserUtils.toBoolean(_local4.children()[0]);
                    break;
                case "notifications.sendEmail":
                    _local3 = this.parseSendEmail(_local4);
                    break;
                case "data.getObjectTypes":
                    _local3 = this.parseGetObjectTypes(_local4);
                    break;
                case "users.getStandardInfo":
                    _local3 = this.parseGetStandardInfo(_local4);
                    break;
                case "data.getObjectType":
                    _local3 = this.parseGetObjectType(_local4);
                    break;
                case "events.get":
                    _local3 = this.parseGetEvent(_local4);
                    break;
                case "events.getMembers":
                    _local3 = this.parseGetMembers(_local4);
                    break;
                case "fql.multiquery":
                    _local3 = new FacebookData();
                    break;
                case "fql.query":
                    _local3 = new FacebookData();
                    break;
                case "photos.createAlbum":
                    _local3 = this.parseCreateAlbum(_local4);
                    break;
                case "photos.get":
                    _local3 = this.parseGetPhotos(_local4);
                    break;
                case "photos.getTags":
                    _local3 = this.parseGetTags(_local4);
                    break;
                case "photos.getAlbums":
                    _local3 = this.parseGetAlbums(_local4);
                    break;
                case "photos.upload":
                    _local3 = this.parseFacebookPhoto(_local4);
                    break;
                case "pages.getInfo":
                    _local3 = this.parsePageGetInfo(_local4);
                    break;
                case "batch.run":
                    _local3 = this.parseBatchRun(_local4);
                    break;
                case "fbml.getCustomTags":
                    _local3 = this.parseGetCustomTags(_local4);
                    break;
                case "connect.unregisterUsers":
                case "connect.registerUsers":
                    _local3 = new ArrayResultData();
                    (_local3 as ArrayResultData).arrayResult = FacebookXMLParserUtils.toArray(_local4);
                    break;
                case "status.get":
                    _local3 = this.parseGetStatus(_local4);
                    break;
                case "stream.get":
                    _local3 = FacebookStreamXMLParser.createStream(_local4, this.fb_namespace);
                    break;
                case "stream.getComments":
                    _local3 = FacebookStreamXMLParser.createGetCommentsData(_local4, this.fb_namespace);
                    break;
                case "stream.getFilters":
                    _local3 = FacebookStreamXMLParser.createStreamFilterCollection(_local4, this.fb_namespace);
                    break;
                case "auth.createToken":
                case "events.create":
                case "links.post":
                case "auth.promoteSession":
                case "admin.getRestrictionInfo":
                case "data.getObjectProperty":
                case "notifications.send":
                case "notes.create":
                case "data.getUserPreference":
                case "profile.setFBML":
                case "users.getLoggedInUser":
                case "stream.addComment":
                default:
                    _local3 = new StringResultData();
                    (_local3 as StringResultData).value = FacebookXMLParserUtils.toStringValue(_local4);
            };
            _local3.rawResult = _arg1;
            return (_local3);
        }
        protected function parseGetStandardInfo(_arg1:XML):GetStandardInfoData{
            var _local4:*;
            var _local5:UserData;
            var _local2:GetStandardInfoData = new GetStandardInfoData();
            var _local3:UserCollection = new UserCollection();
            for each (_local4 in _arg1..this.fb_namespace::user) {
                _local5 = new UserData();
                _local5.uid = _local4.this.fb_namespace::uid;
                _local5.affiations = this.getAffiliation(XML(_local4.this.fb_namespace::affiliations.toXMLString()));
                _local5.first_name = _local4.this.fb_namespace::first_name;
                _local5.last_name = _local4.this.fb_namespace::last_name;
                _local5.name = _local4.this.fb_namespace::name;
                _local5.timezone = _local4.this.fb_namespace::timezone;
                _local3.addItem(_local5);
            };
            _local2.userCollection = _local3;
            return (_local2);
        }
        protected function parseGetAppProperties(_arg1:XML):GetAppPropertiesData{
            var _local2:GetAppPropertiesData = new GetAppPropertiesData();
            _local2.appProperties = JSON.decode(_arg1.toString());
            return (_local2);
        }
        protected function parseGetRegisteredTemplateBundles(_arg1:XML):GetRegisteredTemplateBundleData{
            var _local5:*;
            var _local2:GetRegisteredTemplateBundleData = new GetRegisteredTemplateBundleData();
            var _local3:TemplateBundleCollection = new TemplateBundleCollection();
            var _local4:TemplateCollection = new TemplateCollection();
            for each (_local5 in _arg1..this.fb_namespace::template_bundle) {
                this.getTemplate(_local5.this.fb_namespace::one_line_story_template, _local4);
                this.getTemplate(_local5.this.fb_namespace::short_story_templates, _local4);
                this.getTemplate(_local5.this.fb_namespace::full_story_template, _local4);
                _local4.template_bundle_id = _local5.this.fb_namespace::template_bundle_id;
                _local4.time_created = FacebookXMLParserUtils.toDate(_local5.this.fb_namespace::time_created);
            };
            _local2.bundleCollection = _local4;
            return (_local2);
        }
        protected function parseGetRegisteredTemplateBundleByID(_arg1:XML):GetRegisteredTemplateBundleByIDData{
            var _local2:GetRegisteredTemplateBundleByIDData = new GetRegisteredTemplateBundleByIDData();
            var _local3:TemplateCollection = new TemplateCollection();
            this.getTemplate(_arg1.this.fb_namespace::one_line_story_template, _local3);
            this.getTemplate(_arg1.this.fb_namespace::short_story_templates, _local3);
            this.getTemplate(_arg1.this.fb_namespace::full_story_template, _local3);
            _local3.template_bundle_id = _arg1.this.fb_namespace::template_bundle_id;
            _local3.time_created = FacebookXMLParserUtils.toDate(_arg1.this.fb_namespace::time_created);
            _local2.templateCollection = _local3;
            return (_local2);
        }
        protected function responseNodeNameToMethodName(_arg1:String):String{
            var _local2:Array = _arg1.split("_");
            _local2.pop();
            return (_local2.join("."));
        }
        protected function parseGetObjectTypes(_arg1:XML):GetObjectTypesData{
            var _local4:*;
            var _local5:ObjectTypesData;
            var _local2:GetObjectTypesData = new GetObjectTypesData();
            var _local3:ObjectTypesCollection = new ObjectTypesCollection();
            for each (_local4 in _arg1..this.fb_namespace::object_type_info) {
                _local5 = new ObjectTypesData();
                _local5.name = _local4.this.fb_namespace::name;
                _local5.object_class = _local4.this.fb_namespace::object_class;
                _local3.addItem(_local5);
            };
            _local2.objectTypeCollection = _local3;
            return (_local2);
        }
        protected function parseFacebookPhoto(_arg1:XML):FacebookPhoto{
            var _local2:FacebookPhoto = new FacebookPhoto();
            _local2.pid = FacebookXMLParserUtils.toStringValue(_arg1.this.fb_namespace::pid[0]);
            _local2.aid = FacebookXMLParserUtils.toStringValue(_arg1.this.fb_namespace::aid[0]);
            _local2.owner = FacebookXMLParserUtils.toNumber(_arg1.this.fb_namespace::owner[0]);
            _local2.src = FacebookXMLParserUtils.toStringValue(_arg1.this.fb_namespace::src[0]);
            _local2.src_big = FacebookXMLParserUtils.toStringValue(_arg1.this.fb_namespace::src_big[0]);
            _local2.src_small = FacebookXMLParserUtils.toStringValue(_arg1.this.fb_namespace::src_small[0]);
            _local2.link = FacebookXMLParserUtils.toStringValue(_arg1.this.fb_namespace::link[0]);
            _local2.caption = FacebookXMLParserUtils.toStringValue(_arg1.this.fb_namespace::caption[0]);
            return (_local2);
        }
        protected function parseGetObjectType(_arg1:XML):GetObjectTypeData{
            var _local2:GetObjectTypeData = new GetObjectTypeData();
            _local2.name = _arg1.this.fb_namespace::name;
            _local2.data_type = _arg1.this.fb_namespace::data_type;
            _local2.index_type = _arg1.this.fb_namespace::index_type;
            return (_local2);
        }
        protected function createTagObject(_arg1:XML, _arg2:Array){
            var _local5:AbstractTagData;
            var _local7:Object;
            var _local3:Number = _arg1.children().length();
            var _local4:String = _arg1.children()[0].toLowerCase();
            if (_local4 == "leaf"){
                _local5 = new LeafTagData(null, null, null, null, null);
                (_local5 as LeafTagData).fbml = _arg1.children()[9];
            } else {
                _local5 = new ContainerTagData(null, null, null, null, null, null, null);
                (_local5 as ContainerTagData).open_tag_fbml = _arg1.children()[2];
                (_local5 as ContainerTagData).close_tag_fbml = _arg1.children()[4];
            };
            var _local6:Number = 0;
            while (_local6 < _local3) {
                _local7 = _arg1.children()[_local6];
                switch (_arg2[_local6]){
                    case "name":
                    case "type":
                    case "description":
                    case "is_public":
                    case "header_fbml":
                    case "footer_fbml":
                        _local5[_arg2[_local6]] = _local7.text();
                        break;
                    case "attributes":
                        if ((_local7.children() is XMLList)){
                            if (_local7.children().length() == 0){
                                _local5[_arg2[_local6]] = null;
                            };
                        };
                        break;
                };
                _local6++;
            };
            return (_local5);
        }
        protected function parseGetNotes(_arg1:XML):GetNotesData{
            var _local4:*;
            var _local5:NoteData;
            var _local2:GetNotesData = new GetNotesData();
            var _local3:NotesCollection = new NotesCollection();
            for each (_local4 in _arg1..this.fb_namespace::note) {
                _local5 = new NoteData();
                _local5.note_id = _local4.this.fb_namespace::note_id;
                _local5.title = _local4.this.fb_namespace::title;
                _local5.content = _local4.this.fb_namespace::content;
                _local5.created_time = FacebookXMLParserUtils.toDate(_local4.this.fb_namespace::created_time);
                _local5.updated_time = FacebookXMLParserUtils.toDate(_local4.this.fb_namespace::updated_time);
                _local5.uid = _local4.this.fb_namespace::uid;
                _local3.addItem(_local5);
            };
            _local2.notesCollection = _local3;
            return (_local2);
        }
        protected function parseGetMetrics(_arg1:XML):GetMetricsData{
            var _local4:*;
            var _local5:MetricsData;
            var _local2:GetMetricsData = new GetMetricsData();
            var _local3:MetricsDataCollection = new MetricsDataCollection();
            for each (_local4 in _arg1..this.fb_namespace::metrics) {
                _local5 = new MetricsData();
                _local5.end_time = FacebookXMLParserUtils.toDate(_local4.this.fb_namespace::end_time);
                _local5.active_users = _local4.this.fb_namespace::active_users;
                _local5.canvas_page_views = _local4.this.fb_namespace::canvas_page_views;
                _local3.addItem(_local5);
            };
            _local2.metricsCollection = _local3;
            return (_local2);
        }
        protected function parsePageGetInfo(_arg1:XML):GetPageInfoData{
            var _local5:Object;
            var _local6:PageInfoData;
            var _local2:GetPageInfoData = new GetPageInfoData();
            var _local3:PageInfoCollection = new PageInfoCollection();
            var _local4:XMLList = _arg1.this.fb_namespace::page;
            for each (_local5 in _local4) {
                _local6 = new PageInfoData();
                _local6.page_id = _local5.this.fb_namespace::page_id;
                _local6.name = _local5.this.fb_namespace::name;
                _local6.pic_small = _local5.this.fb_namespace::pic_small;
                _local6.pic_big = _local5.this.fb_namespace::pic_big;
                _local6.pic_square = _local5.this.fb_namespace::pic_square;
                _local6.pic_large = _local5.this.fb_namespace::pic_large;
                _local6.type = _local5.this.fb_namespace::type;
                _local6.website = _local5.this.fb_namespace::website;
                _local6.location = FacebookXMLParserUtils.createLocation(_local5.this.fb_namespace::location[0], this.fb_namespace);
                _local6.hours = _local5.this.fb_namespace::hours;
                _local6.band_members = _local5.this.fb_namespace::band_members;
                _local6.bio = _local5.this.fb_namespace::bio;
                _local6.hometown = _local5.this.fb_namespace::hometown;
                _local6.genre = FacebookXMLParserUtils.toStringValue(_local5.this.fb_namespace::genre[0]);
                _local6.record_label = _local5.this.fb_namespace::record_label;
                _local6.influences = _local5.this.fb_namespace::influences;
                _local6.has_added_app = FacebookXMLParserUtils.toBoolean(_local5.this.fb_namespace::has_added_app[0]);
                _local6.founded = _local5.this.fb_namespace::founded;
                _local6.company_overview = _local5.this.fb_namespace::company_overview;
                _local6.mission = _local5.this.fb_namespace::mission;
                _local6.products = _local5.this.fb_namespace::products;
                _local6.release_date = _local5.this.fb_namespace::release_date;
                _local6.starring = _local5.this.fb_namespace::starring;
                _local6.written_by = _local5.this.fb_namespace::written_by;
                _local6.directed_by = _local5.this.fb_namespace::directed_by;
                _local6.produced_by = _local5.this.fb_namespace::produced_by;
                _local6.studio = _local5.this.fb_namespace::studio;
                _local6.awards = _local5.this.fb_namespace::awards;
                _local6.plot_outline = _local5.this.fb_namespace::plot_outline;
                _local6.network = _local5.this.fb_namespace::network;
                _local6.season = _local5.this.fb_namespace::season;
                _local6.schedule = _local5.this.fb_namespace::schedule;
                _local3.addPageInfo(_local6);
            };
            _local2.pageInfoCollection = _local3;
            return (_local2);
        }
        protected function parseGetTags(_arg1:XML):GetTagsData{
            var _local4:*;
            var _local5:TagData;
            var _local2:GetTagsData = new GetTagsData();
            var _local3:PhotoTagCollection = new PhotoTagCollection();
            for each (_local4 in _arg1..this.fb_namespace::photo_tag) {
                _local5 = new TagData();
                _local5.text = _local4.this.fb_namespace::text;
                _local5.pid = _local4.this.fb_namespace::pid;
                _local5.subject = _local4.this.fb_namespace::subject;
                _local5.xcoord = _local4.this.fb_namespace::xcoord;
                _local5.ycoord = _local4.this.fb_namespace::ycoord;
                _local5.created = FacebookXMLParserUtils.toDate(_local4.this.fb_namespace::created);
                _local3.addPhotoTag(_local5);
            };
            _local2.photoTagsCollection = _local3;
            return (_local2);
        }
        protected function parseGetGroupMembers(_arg1:XML):GetMemberData{
            var _local2:GetMemberData = new GetMemberData();
            _local2.members = FacebookXMLParserUtils.toUIDArray(_arg1.this.fb_namespace::members[0]);
            _local2.admins = FacebookXMLParserUtils.toUIDArray(_arg1.this.fb_namespace::admins[0]);
            _local2.officers = FacebookXMLParserUtils.toUIDArray(_arg1.this.fb_namespace::officers[0]);
            _local2.notReplied = FacebookXMLParserUtils.toUIDArray(_arg1.this.fb_namespace::not_replied[0]);
            return (_local2);
        }
        protected function parseGetGroups(_arg1:XML):GetGroupData{
            var _local4:*;
            var _local5:GroupData;
            var _local2:GetGroupData = new GetGroupData();
            var _local3:GroupCollection = new GroupCollection();
            for each (_local4 in _arg1..this.fb_namespace::group) {
                _local5 = new GroupData();
                _local5.gid = _local4.this.fb_namespace::gid;
                _local5.name = _local4.this.fb_namespace::name;
                _local5.nid = _local4.this.fb_namespace::nid;
                _local5.description = _local4.this.fb_namespace::description;
                _local5.group_type = _local4.this.fb_namespace::group_type;
                _local5.group_subtype = _local4.this.fb_namespace::group_subtype;
                _local5.recent_news = _local4.this.fb_namespace::recent_news;
                _local5.pic = _local4.this.fb_namespace::pic;
                _local5.pic_big = _local4.this.fb_namespace::pic_big;
                _local5.pic_small = _local4.this.fb_namespace::pic_small;
                _local5.creator = _local4.this.fb_namespace::creator;
                _local5.update_time = FacebookXMLParserUtils.toDate(_local4.this.fb_namespace::update_time);
                _local5.office = _local4.this.fb_namespace::office;
                _local5.website = _local4.this.fb_namespace::website;
                _local5.venue = FacebookXMLParserUtils.createLocation(_local4.this.fb_namespace::venue[0], this.fb_namespace);
                _local5.privacy = _local4.this.fb_namespace::privacy;
                _local3.addGroup(_local5);
            };
            _local2.groups = _local3;
            return (_local2);
        }
        protected function parseCreateAlbum(_arg1:XML):GetCreateAlbumData{
            var _local2:GetCreateAlbumData = new GetCreateAlbumData();
            var _local3:AlbumData = new AlbumData();
            _local3.aid = _arg1.this.fb_namespace::aid;
            _local3.cover_pid = _arg1.this.fb_namespace::cover_pid;
            _local3.owner = _arg1.this.fb_namespace::owner;
            _local3.name = _arg1.this.fb_namespace::name;
            _local3.created = FacebookXMLParserUtils.toDate(_arg1.this.fb_namespace::created);
            _local3.modified = FacebookXMLParserUtils.toDate(_arg1.this.fb_namespace::modified);
            _local3.description = _arg1.this.fb_namespace::description;
            _local3.location = _arg1.this.fb_namespace::location;
            _local3.link = _arg1.this.fb_namespace::link;
            _local3.size = _arg1.this.fb_namespace::size;
            _local3.visible = _arg1.this.fb_namespace::visible;
            _local2.albumData = _local3;
            return (_local2);
        }
        protected function parseGetAllocation(_arg1:XML):GetAllocationData{
            var _local2:GetAllocationData = new GetAllocationData();
            _local2.allocationLimit = Number(_arg1.toString());
            return (_local2);
        }
        protected function parseGetCookies(_arg1:XML):GetCookiesData{
            var _local2:GetCookiesData = new GetCookiesData();
            _local2.uid = _arg1.this.fb_namespace::uid;
            _local2.name = _arg1.this.fb_namespace::name;
            _local2.value = _arg1.this.fb_namespace::value;
            _local2.expires = _arg1.this.fb_namespace::expires;
            _local2.path = _arg1.this.fb_namespace::path;
            return (_local2);
        }
        protected function parseGetCustomTags(_arg1:XML):GetCustomTagsData{
            var _local5:*;
            var _local2:Array = ["type", "name", "open_tag_fbml", "description", "close_tag_fbml", "is_public", "attributes", "header_fbml", "footer_fbml", "fbml"];
            var _local3:GetCustomTagsData = new GetCustomTagsData();
            var _local4:TagCollection = new TagCollection();
            for each (_local5 in _arg1..this.fb_namespace::custom_tag) {
                _local4.addItem(this.createTagObject(_local5, _local2));
            };
            _local3.tagCollection = _local4;
            return (_local3);
        }
        protected function parseGetAlbums(_arg1:XML):GetAlbumsData{
            var _local2:GetAlbumsData = new GetAlbumsData();
            _local2.albumCollection = FacebookXMLParserUtils.createAlbumCollection(_arg1, this.fb_namespace);
            return (_local2);
        }
        protected function parseGetInfo(_arg1:XML):GetInfoData{
            var _local7:FacebookUser;
            var _local2:FacebookUserCollection = new FacebookUserCollection();
            var _local3:XMLList = _arg1..this.fb_namespace::user;
            var _local4:uint = _local3.length();
            var _local5:uint;
            while (_local5 < _local4) {
                _local7 = FacebookUserXMLParser.createFacebookUser(_local3[_local5], this.fb_namespace);
                _local2.addItem(_local7);
                _local5++;
            };
            var _local6:GetInfoData = new GetInfoData();
            _local6.userCollection = _local2;
            return (_local6);
        }
        protected function parseGetLists(_arg1:XML):GetListsData{
            var _local4:*;
            var _local5:ListsData;
            var _local2:GetListsData = new GetListsData();
            var _local3:Array = [];
            for each (_local4 in _arg1..this.fb_namespace::friendlist) {
                _local5 = new ListsData();
                _local5.flid = _local4.this.fb_namespace::flid;
                _local5.name = _local4.this.fb_namespace::name;
                _local3.push(_local5);
            };
            _local2.lists = _local3;
            return (_local2);
        }
        protected function parseGetAppUsersData(_arg1:XML):GetAppUserData{
            var _local2:Array = FacebookXMLParserUtils.toUIDArray(_arg1);
            var _local3:GetAppUserData = new GetAppUserData();
            _local3.uids = _local2;
            return (_local3);
        }
        protected function parseGetStatus(_arg1:XML):GetStatusData{
            var _local7:XML;
            var _local8:Status;
            var _local2:GetStatusData = new GetStatusData();
            var _local3:Array = [];
            var _local4:XMLList = _arg1.children();
            var _local5:uint = _local4.length();
            var _local6:uint;
            while (_local6 < _local5) {
                _local7 = _local4[_local6];
                _local8 = new Status();
                _local8.uid = FacebookXMLParserUtils.toStringValue(_local7.this.fb_namespace::uid[0]);
                _local8.status_id = FacebookXMLParserUtils.toStringValue(_local7.this.fb_namespace::status_id[0]);
                _local8.time = FacebookXMLParserUtils.toDate(_local7.this.fb_namespace::time[0]);
                _local8.source = FacebookXMLParserUtils.toStringValue(_local7.this.fb_namespace::source[0]);
                _local8.message = FacebookXMLParserUtils.toStringValue(_local7.this.fb_namespace::message[0]);
                _local3.push(_local8);
                _local6++;
            };
            _local2.status = _local3;
            return (_local2);
        }
        protected function parseGetMembers(_arg1:XML):GetMembersData{
            var _local2:GetMembersData = new GetMembersData();
            _local2.attending = FacebookXMLParserUtils.toUIDArray(_arg1..this.fb_namespace::attending[0]);
            _local2.unsure = FacebookXMLParserUtils.toUIDArray(_arg1..this.fb_namespace::unsure[0]);
            _local2.declined = FacebookXMLParserUtils.toUIDArray(_arg1..this.fb_namespace::declined[0]);
            _local2.not_replied = FacebookXMLParserUtils.toUIDArray(_arg1..this.fb_namespace::not_replied[0]);
            return (_local2);
        }
        protected function parseGetEvent(_arg1:XML):GetEventsData{
            var _local4:*;
            var _local5:EventData;
            var _local2:GetEventsData = new GetEventsData();
            var _local3:EventCollection = new EventCollection();
            for each (_local4 in _arg1..this.fb_namespace::event) {
                _local5 = new EventData();
                _local5.eid = _local4.this.fb_namespace::eid;
                _local5.name = _local4.this.fb_namespace::name;
                _local5.tagline = _local4.this.fb_namespace::tagline;
                _local5.nid = _local4.this.fb_namespace::nid;
                _local5.pic = _local4.this.fb_namespace::pic;
                _local5.pic_big = _local4.this.fb_namespace::pic_big;
                _local5.pic_small = _local4.this.fb_namespace::pic_small;
                _local5.host = _local4.this.fb_namespace::host;
                _local5.description = _local4.this.fb_namespace::description;
                _local5.event_type = _local4.this.fb_namespace::event_type;
                _local5.event_subtype = _local4.this.fb_namespace::event_subtype;
                _local5.start_time = FacebookXMLParserUtils.toDate(_local4.this.fb_namespace::start_time);
                _local5.end_time = FacebookXMLParserUtils.toDate(_local4.this.fb_namespace::end_time);
                _local5.creator = _local4.this.fb_namespace::end_time;
                _local5.update_time = FacebookXMLParserUtils.toDate(_local4.this.fb_namespace::update_time);
                _local5.location = _local4.this.fb_namespace::location;
                _local5.venue = FacebookXMLParserUtils.createLocation(_local4.this.fb_namespace::venue[0], this.fb_namespace);
                _local3.addItem(_local5);
            };
            _local2.eventCollection = _local3;
            return (_local2);
        }
        protected function parseGetFriends(_arg1:XML):GetFriendsData{
            var _local4:*;
            var _local5:FacebookUser;
            var _local2:GetFriendsData = new GetFriendsData();
            var _local3:FacebookUserCollection = new FacebookUserCollection();
            for each (_local4 in _arg1..this.fb_namespace::uid) {
                _local5 = new FacebookUser();
                _local5.uid = _local4;
                _local3.addItem(_local5);
            };
            _local2.friends = _local3;
            return (_local2);
        }
        protected function parseGetPublicInfo(_arg1:XML):GetPublicInfoData{
            var _local2:GetPublicInfoData = new GetPublicInfoData();
            _local2.app_id = _arg1.this.fb_namespace::app_id;
            _local2.api_key = _arg1.this.fb_namespace::api_key;
            _local2.canvas_name = _arg1.this.fb_namespace::canvas_name;
            _local2.display_name = _arg1.this.fb_namespace::display_name;
            _local2.icon_url = _arg1.this.fb_namespace::icon_url;
            _local2.logo_url = _arg1.this.fb_namespace::logo_url;
            _local2.developers = _arg1.this.fb_namespace::developers;
            _local2.company_name = _arg1.this.fb_namespace::company_name;
            _local2.developers = _arg1.this.fb_namespace::developers;
            _local2.daily_active_users = _arg1.this.fb_namespace::daily_active_users;
            _local2.weekly_active_users = _arg1.this.fb_namespace::weekly_active_users;
            _local2.monthly_active_users = _arg1.this.fb_namespace::monthly_active_users;
            _local2.description = _arg1.this.fb_namespace::description;
            return (_local2);
        }
        protected function parseAreFriends(_arg1:XML):AreFriendsData{
            var _local4:*;
            var _local5:FriendsData;
            var _local2:AreFriendsData = new AreFriendsData();
            var _local3:FriendsCollection = new FriendsCollection();
            for each (_local4 in _arg1..this.fb_namespace::friend_info) {
                _local5 = new FriendsData();
                _local5.uid1 = _local4.this.fb_namespace::uid1;
                _local5.uid2 = _local4.this.fb_namespace::uid2;
                _local5.are_friends = FacebookXMLParserUtils.toBoolean(XML(_local4.this.fb_namespace::are_friends.toXMLString()));
                _local3.addItem(_local5);
            };
            _local2.friendsCollection = _local3;
            return (_local2);
        }
        public function validateFacebookResponce(_arg1:String):FacebookError{
            var xml:* = null;
            var xmlError:* = null;
            var result:* = _arg1;
            var error:* = null;
            var hasXMLError:* = false;
            try {
                xml = new XML(result);
            } catch(e) {
                xmlError = e;
                hasXMLError = true;
            };
            if (hasXMLError == false){
                if (xml.localName() == "error_response"){
                    error = new FacebookError();
                    error.rawResult = result;
                    error.errorCode = Number(xml.this.fb_namespace::error_code);
                    error.errorMsg = xml.this.fb_namespace::error_msg;
                    error.requestArgs = FacebookXMLParserUtils.xmlToUrlVariables(xml..arg);
                };
                return (error);
            };
            if (hasXMLError == true){
                error = new FacebookError();
                error.error = xmlError;
                error.errorCode = -1;
            };
            return (error);
        }
        protected function parseBatchRun(_arg1:XML):FacebookData{
            var _local7:String;
            var _local8:XML;
            var _local9:FacebookError;
            var _local10:String;
            var _local11:FacebookData;
            var _local2:XMLList = _arg1..this.fb_namespace::batch_run_response_elt;
            var _local3:uint = _local2.length();
            var _local4:Array = [];
            var _local5:uint;
            while (_local5 < _local3) {
                _local7 = _local2[_local5].toString();
                _local8 = new XML(_local7);
                _local9 = this.validateFacebookResponce(_local7);
                if (_local9 === null){
                    _local10 = this.responseNodeNameToMethodName(_local8.localName().toString());
                    _local11 = this.parse(_local7, _local10);
                    _local4.push(_local11);
                } else {
                    _local4.push(_local9);
                };
                _local5++;
            };
            var _local6:BatchResult = new BatchResult();
            _local6.results = _local4;
            return (_local6);
        }
        protected function getTemplate(_arg1:XMLList, _arg2:TemplateCollection):void{
            var _local3:*;
            var _local4:TemplateData;
            for each (_local3 in _arg1) {
                _local4 = new TemplateData();
                _local4.type = _local3.localName();
                _local4.template_body = _local3.this.fb_namespace::template_body;
                _local4.template_title = _local3.this.fb_namespace::template_title;
                _arg2.addTemplateData(_local4);
            };
        }

    }
}//package com.facebook.data 
